/*
 * @Author: tianchunyu
 * @Date: 2020-05-16 11:02:54
 * @LastEditTime: 2020-05-17 13:45:41
 * @LastEditors: Please set LastEditors
 * @Description: the drive of the brush structure of the car washing robot
 * @FilePath: \app\xp\driver\syntron\brush_s.h
 */ 
#ifndef _BRUSH_S_H_
#define _BRUSH_S_H_
#include "synron_ls_modbus.h"
/*电机和刷子的减速比  为  1:15*/
#define BRUSH_RATED_SPEED   (1400)      // unit prm
#define ACC_DCC_TIME        (1500)       //加减速 时间ms
#define ACC_TIME            (1500)       //加速 时间ms  
#define DCC_TIME            (1500)       //减速 时间 ms

typedef enum{
    brush_dir_no=0,
    brush_dir_a,    //正转 
    brush_dir_b,    //反转
    brush_dir_change
}BRUSH_dir;


typedef enum{
    brush_speed_master=0,
    brush_speed_1,
    brush_speed_2,
    brush_speed_3,
    brush_speedmax,
}BRUSH_speed;

typedef enum{
    brush_exp_1=0,
    brush_exp_2,
    brush_exp_3,
    brush_exp_4,
}BRUSH_exp;

typedef enum{
    brush_run_no=0,
    brush_run_start,
    brush_run_stop,
    brush_run_jog
}BRUSH_run;

typedef struct{
    u8 init;    //init state
    u8 run;    //run state,0=stop,1=ruun,2=jog
    u8 dir;    //run direction,0 no  1 positive 2 negative 3 change dir
    u8 exp;    //run expedite choose,1=first....1~4
    u16 acc_dcctime; //加减速时间      unit ms
    u8 speed_grade ;// run speed choose 0=default,1~5
    u8 res;//       reserve
    u16 torque_rate;//有效转矩率
    u8 res1[2];
    SYNRO_handler * brush_syn_hander ;   //motor object pointer
}BRUSH_state;


/*
input singal defination 
*/
#define B_BOARD_ID              (1)   
#define B_INPUT_PIN             (1)   //向左电机输入信号引脚
#define B_HIGH_STATE            (1)   //输入信号高电平状态
#define B_LOW_STATE             (0)    // 输入信号低电平状态
#define B_IPUT_DRIVE_EMG_PIN    (1)   //驱动器紧急停转信号输入引脚 范围 1~4

extern void xp_brush_config(void);
extern int xp_brush_set_motors_acc_timems(u16 time_ms);
extern int xp_brush_set_motors_dcc_timems(u16 time_ms);
extern int xp_brush_set_acc_dcc_times(u16 time_ms);
extern int xp_brush_init(u8 port,int speed,u8 slaveid);
extern int xp_brush_stop();
extern int xp_brush_rotate(u8 dir ,u8 grade);
extern int xp_brush_debug(char *type,char *fun,char *param);
extern int xp_brush_read_fluent_feedback();
extern void xp_io_test_verify();

#endif
